home *** CD-ROM | disk | FTP | other *** search
- on startMovie
- set the textHeight of member "selection menu" to 14
- set the textHeight of member "timePeriod translation" to 14
- end
-
- on findHits
- global gSearchObj, gEnvironObj
- kEmptyType = 0
- kFreeFindType = 3
- t = the ticks
- menuBankObj = getMenuBankObj(gSearchObj)
- hitList = performSearch(1)
- menuType = getMenuSelection(menuBankObj, 2, #criteria)
- if menuType > 0 then
- newList = performSearch(2)
- conjunction = getMenuSelection(menuBankObj, 2, #andOr)
- case conjunction of
- 1:
- hitList = intersectSumValues(hitList, newList)
- 2:
- hitList = unionSumValues(hitList, newList)
- end case
- end if
- menuType = getMenuSelection(menuBankObj, 3, #criteria)
- if menuType > 0 then
- newList = performSearch(3)
- conjunction = getMenuSelection(menuBankObj, 3, #andOr)
- case conjunction of
- 1:
- hitList = intersectSumValues(hitList, newList)
- 2:
- hitList = unionSumValues(hitList, newList)
- end case
- end if
- put "Search took " & the ticks - t & " ticks."
- sendToResultsWindow(hitList)
- end
-
- on performSearch bankNum
- global gSearchObj, gTextBaseObj
- kEmptyType = 0
- kCategoryType = 1
- kTimePeriodType = 2
- kFreeFindType = 3
- menuBankObj = getMenuBankObj(gSearchObj)
- menuType = getMenuSelection(menuBankObj, bankNum, #criteria)
- menuText = getMenuText(menuBankObj, bankNum, #selection)
- case menuType of
- kEmptyType:
- beep()
- kCategoryType:
- selection = getMenuSelection(menuBankObj, bankNum, #selection)
- hitList = getHitList(menuType, selection)
- kTimePeriodType:
- selection = getMenuSelection(menuBankObj, bankNum, #selection)
- hitList = getHitList(menuType, selection)
- kFreeFindType:
- if stripPunct(translate(menuText)) contains " " then
- hitList = getPhraseHits(menuText)
- else
- targetWord = stripPunct(translate(filterChar(menuText, ",")))
- if length(targetWord) < 2 then
- hitList = [:]
- alert("Your free find must contain at least two characters." & RETURN & "Invalid entries will be ignored.")
- else
- hitList = seekPartial(gTextBaseObj, targetWord)
- if not listp(hitList) then
- hitList = [:]
- if hitList <> 1 then
- alert("Error " & hitList & " when trying to get word hits.")
- end if
- end if
- end if
- end if
- end case
- return hitList
- end
-
- on sendToResultsWindow scoreList
- criteria = buildCriteriaDisplay()
- if count(scoreList) = 0 then
- hitList = [:]
- titles = EMPTY
- else
- scoreList = relevanceSort(scoreList)
- hitList = getPropListProps(scoreList)
- titles = getTitles(hitList)
- end if
- windowName = "Search Results"
- if windowPresent(windowName) then
- moveToFront(window(windowName))
- else
- tell the stage
- openSearchResultsWindow()
- end tell
- end if
- if windowPresent(windowName) then
- tell window(windowName)
- setSearchResultsList(titles, hitList, criteria)
- end tell
- else
- end if
- end
-
- on sendKeywordsToResultsWindow scoreList
- criteria = buildCriteriaDisplay()
- if count(scoreList) = 0 then
- hitList = [:]
- titles = EMPTY
- else
- scoreList = AlphaSort(scoreList)
- hitList = getPropListProps(scoreList)
- titles = getTitles(hitList)
- end if
- windowName = "Search Results"
- if windowPresent(windowName) then
- moveToFront(window(windowName))
- else
- tell the stage
- openSearchResultsWindow()
- end tell
- end if
- if windowPresent(windowName) then
- tell window(windowName)
- setSearchResultsList(titles, hitList, criteria)
- end tell
- else
- end if
- end
-
- on buildCriteriaDisplay
- global gSearchObj
- menuBankObj = getMenuBankObj(gSearchObj)
- if getContext(gSearchObj) = #keywords then
- criteria = "Keyword Search" & RETURN & RETURN
- else
- criteria = getMenuText(menuBankObj, 1, #criteria) & " = "
- put getMenuText(menuBankObj, 1, #selection) & RETURN after menuBankObj
- if getMenuSelection(menuBankObj, 2, #selection) = 0 then
- put RETURN after menuBankObj
- else
- put getMenuText(menuBankObj, 2, #andOr) & " " after menuBankObj
- put getMenuText(menuBankObj, 2, #criteria) & " = " after menuBankObj
- put getMenuText(menuBankObj, 2, #selection) & RETURN after menuBankObj
- end if
- if getMenuSelection(menuBankObj, 3, #selection) = 0 then
- put RETURN after menuBankObj
- else
- put getMenuText(menuBankObj, 3, #andOr) & " " after menuBankObj
- put getMenuText(menuBankObj, 3, #criteria) & " = " after menuBankObj
- put getMenuText(menuBankObj, 3, #selection) & RETURN after menuBankObj
- end if
- end if
- return criteria
- end
-
- on relevanceSort scoreList
- scoreList = swapPropList(scoreList)
- sort(scoreList)
- resultList = [:]
- n = count(scoreList)
- repeat while n > 0
- subsectionList = [:]
- score = getPropAt(scoreList, n)
- recnum = getAt(scoreList, n)
- addProp(subsectionList, recnum, score)
- repeat while 1
- n = n - 1
- if n = 0 then
- exit repeat
- end if
- if score <> getPropAt(scoreList, n) then
- exit repeat
- end if
- addProp(subsectionList, getAt(scoreList, n), getPropAt(scoreList, n))
- end repeat
- sort(subsectionList)
- end = count(subsectionList)
- repeat with m = 1 to end
- recnum = getPropAt(subsectionList, m)
- resultListValue = getaProp(resultList, recnum)
- if voidp(resultListValue) then
- addProp(resultList, recnum, getAt(subsectionList, m))
- next repeat
- end if
- setaProp(resultList, recnum, resultListValue + getAt(subsectionList, m))
- end repeat
- end repeat
- return resultList
- end
-
- on AlphaSort scoreList
- newList = [:]
- sort(scoreList)
- end = count(scoreList)
- repeat with m = 1 to end
- CurrProp = getPropAt(scoreList, m)
- NextM = min(m + 1, end)
- NextProp = getPropAt(scoreList, NextM)
- if (CurrProp <> NextProp) or (NextM = end) then
- value = getaProp(scoreList, m)
- setaProp(newList, CurrProp, value)
- end if
- end repeat
- return newList
- end
-
- on getHitList menuType, selection
- global gTextBaseObj
- menuNameList = ["CATEGORY", "TMPRD"]
- menuName = getAt(menuNameList, menuType)
- hitList = lookup(gTextBaseObj, menuName, integer(selection))
- if not listp(hitList) then
- alert("Error " & hitList & " when trying to get word hits.")
- hitList = [:]
- end if
- return hitList
- end
-
- on getPhraseHits targetPhrase
- global gTextBaseObj
- hitList = [:]
- targetPhrase = cleanWOrds(translate(filterChar(targetPhrase, ",")))
- end = the number of words in targetPhrase
- repeat with n = 1 to end
- theWord = word n of targetPhrase
- if length(theWord) > 1 then
- if n = end then
- newHitList = seekPartial(gTextBaseObj, theWord)
- else
- newHitList = seek(gTextBaseObj, theWord)
- end if
- if not listp(newHitList) then
- alert("Error " & newHitList & " when trying to get phrase hit list.")
- newHitList = [:]
- end if
- if hitList = [:] then
- hitList = value(string(newHitList))
- next repeat
- end if
- hitList = intersectMinValue(hitList, newHitList)
- end if
- end repeat
- if voidp(hitList) then
- hitList = [:]
- end if
- hitList = verifyPhrases(hitList, targetPhrase)
- return hitList
- end
-
- on cleanWOrds thePhrase
- result = stripPunct(word 1 of thePhrase)
- repeat with n = 2 to the number of words in thePhrase
- result = result && stripPunct(word n of thePhrase)
- end repeat
- return result
- end
-
- on verifyPhrases hitList, targetPhrase
- phraseObj = new(script("phrase class"))
- end = count(hitList)
- resultList = [:]
- score = 100
- repeat with recnum = 1 to end
- hasPhrase = fileContainsPhrase(phraseObj, getPropAt(hitList, recnum), targetPhrase)
- updateStage()
- if hasPhrase then
- score = getAt(hitList, recnum)
- addProp(resultList, getPropAt(hitList, recnum), score)
- end if
- end repeat
- phraseObj = 0
- return resultList
- end
-
- on getTitles recordNumberList
- titlesText = the text of field "titles list" of castLib "Update.cst"
- titles = EMPTY
- repeat with recnum in recordNumberList
- put line recnum of titlesText & RETURN after titlesText
- end repeat
- return titles
- end
-
- on alphabetClick whichField
- global gSearchObj
- shadeLoc = [5, 20, 35, 50, 64, 78, 92, 107, 119, 131, 145, 159, 173, 189, 204, 219, 233, 249, 263, 277, 291, 305, 321, 337, 351, 364, 380]
- end = count(shadeLoc)
- repeat with i = 2 to end
- if (the clickLoc).locH < getAt(shadeLoc, i) then
- kGrayBoxSprite = 6
- puppetSprite(kGrayBoxSprite, 1)
- boxLoc = getAt(shadeLoc, i - 1)
- set the locH of sprite kGrayBoxSprite to boxLoc
- letter = char i - 1 of "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- if letter = "A" then
- setThumb(getScrollbarObj(gSearchObj), 0)
- else
- whichField.scrollTop = 0
- CharNum = offset("— " & letter, the text of field whichField)
- if CharNum > 0 then
- charLoc = charPosToLoc(whichField, CharNum)
- lineNumber = locVToLinePos(whichField, charLoc.locV)
- if the machineType = 256 then
- lineNumber = lineNumber - 1
- end if
- setThumb(getScrollbarObj(gSearchObj), lineNumber)
- end if
- end if
- exit repeat
- end if
- end repeat
- end
-